---
title: 'Publish Custom Pieces'
icon: 'upload'
---

You can use the CLI to publish custom pieces to the platform. This process packages the pieces and uploads them to the specified API endpoint.

### How It Works

The CLI scans the `packages/pieces/` directory for the specified piece. It checks the **name** and **version** in the `package.json` file. If the piece is not already published, it builds, packages, and uploads it to the platform using the API.

### Usage

To publish a piece, follow these steps:

1. Ensure you have an API Key. Generate it from the Admin Interface by navigating to Settings.
2. Install the CLI by cloning the repository.
3. Run the following command, replacing `API_KEY` with your generated API Key, `INSTANCE_URL` with your instance URL, and `PIECE_NAME` with the name of the piece you want to publish:

```bash
AP_API_KEY=your_api_key_here npm run pieces -- publish --apiUrl https://INSTANCE_URL/api --name PIECE_NAME
```

